﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EntityCodeGenerate
{
    public partial class TableList : Form
    {
        public DataSet tableSource;

        public TableList()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            CkbListTable.DataSource = tableSource.Tables[0];
            CkbListTable.ValueMember = "id";
            CkbListTable.DisplayMember = "name";
        }

        /// <summary>
        /// 生成
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnGenerate_Click(object sender, EventArgs e)
        {
            string id;
            string name;
            foreach (DataRowView item in CkbListTable.CheckedItems)
            {
                id = item.Row["id"].ToString();
                name = item.Row["name"].ToString();
            }
        }

        /// <summary>
        /// 全选
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CbxAll_CheckedChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < CkbListTable.Items.Count; i++)
            {
                CkbListTable.SetItemChecked(i, CbxAll.Checked);
            }
        }
    }
}
